<?php

class User_ParadesController extends Zend_Controller_Action
{

    public function init()
    {
        $mail = $this->_getParam('mail', NULL);
        $token = $this->_getParam('token', NULL);
        $res = 0;
        if(is_null($mail) || is_null($token)){
            $res = -1;
            echo Zend_Json_Encoder::encode("-1");
        } else {
            $model_auth = new User_Model_AuthUsers();
            $auth = $model_auth->checkToken($mail,$token); 
            
            if($auth != 0)  echo Zend_Json_Encoder::encode("-4");
        }

        if($res == -1 || $auth != 0){
            exit;
        }
    }

    public function indexAction()
    {

    }

    public function getAction(){
        $posx = $this->_getParam('posX', NULL);
        $posy = $this->_getParam('posY', NULL);
        
        if(is_null($posx) || is_null($posy)){
            $res = -1;
        } else {
            $model_parades = new User_Model_Parades();
            $res = $model_parades->get_10_parades_properes($posx, $posy);
        }
        
        echo Zend_Json_Encoder::encode($res);
        exit;  
    }

}

